#include "declarations.h"
using namespace std;

void schedule::List()
{
	ifstream input;
	input.open("schedule.txt");
	char a[100];
		while (input.good())
		{
			input.getline(a,99);
			cout<<a<<'\n';
		}
	input.close();
	return;
}
void schedule::Add()
{
	char a[200];
	cout<<"insert start city ";
	cin.getline(a,20);
	strcat(a,"->");
	char oper[150];
	cout<<"destination city ";
	cin.getline(oper,20);
	strcat(a,oper);
	strcat(a,",");
	cout<<"Date (DD.MM.YYYY) ";
	cin.getline(oper,12);
	strcat(a,oper);
	strcat(a,",");
	cout<<"Time of departure ";
	cin.getline(oper,12);
	strcat(a,oper);
	strcat(a,",");
	cout<<"Train ID ";
	cin.getline(oper,12);
	strcat(a,oper);
	strcat(a,",");
	cout<<"Ticket price ";
	cin.getline(oper,12);
	strcat(a,oper);
	ofstream output;
	output.open("schedule.txt",ofstream::app);
	output<<a;
	output.close();
}
void schedule::Search()
{
	char a[200];
	cout<<"insert start city ";
	cin.getline(a,20);
	strcat(a,"->");
	char oper[150];
	cout<<"destination city ";
	cin.getline(oper,20);
	strcat(a,oper);
	ifstream input;
	input.open("schedule.txt");
	char varr[200];
	while (input.good())
	{
		input.getline(varr,200);
		if (strstr(varr,a)) cout<<strstr(varr,a)<<'\n';
	}
	input.close();
	return;
}
int schedule::CheckSchedule(char* input)
{	
	char varr[200];
	int line=0;
	ifstream instream;
	instream.open("schedule.txt");
		while (instream.good())
	{
		instream.getline(varr,200);
		if (strstr(varr,input)) return line;
		else line++;
	}
	instream.close();
	return -1;
}




schedule::schedule(void)
{
}


schedule::~schedule(void)
{
}
